package day04;


import java.util.Deque;
import java.util.Queue;

public class MyDeque {
    final static int N = 10000;
    int[] data = new int[N];
    int head = N >> 1, tail = head - 1;//a[head::tail]

    void offerLast(int x) {
        data[++tail] = x;
    }

    void offerFirst(int x) {
        data[--head] = x;
    }

    void pullFirst() {
        ++head;
    }

    void pullLast() {
        --tail;
    }

    int front() {
        return data[head];
    }

    int rear() {
        return data[tail];
    }

    int size() {
        return tail - head + 1;
    }

    boolean empty() {
        return head > tail;
    }

    public static void main(String[] args) {
        MyDeque queue = new MyDeque();//FIFO
        for (int i = 1; i <= 10; i++) {
            queue.offerFirst(i);
        }
        while (!queue.empty()) {
            System.out.print(queue.rear() + " ");
            queue.pullLast();
        }
        Queue q;
        Deque q2;
    }
}